package shs.config;

import com.alibaba.druid.FastsqlException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import shs.bean.Cat;
import shs.bean.Dog;
import shs.bean.Pig;
import shs.bean.User;

@Configuration
public class AppConfig02 {
    public static void main(String[] args) {
    }
    @Bean
    @ConditionalOnClass(name="com.alibaba.druid.FastsqlException")
    public Cat cat02(){
        return new Cat();
    }
    @Bean
    @ConditionalOnMissingClass(value="com.alibaba.druid.FastsqlException")
    public Dog dog02(){
        return new Dog();
    }
    @Bean
    @ConditionalOnBean(value = Dog.class)
    public User zhangsan(){
        return new User();
    }
    @Bean
    @ConditionalOnMissingBean(value = Dog.class)
    public User lisi(){
        return new User();
    }

    @Bean
    public Pig pig(){
        return new Pig();
    }
}
